package com.fliad.ai.dto.taskmodel;

import cn.hutool.core.util.IdUtil;
import lombok.Data;

import java.util.HashMap;
import java.util.Map;

@Data
public class TaskReportOutput {

    private String id;
    // 任务输入
    private Map<String, Object> inputs;
    // 任务输出
    private Map<String, Object> outputs;
    private StatusData workflowStatus;
    private Map<String, NodeReport> reports;

    public TaskReportOutput(Map<String, Object> inputs) {
        this.id = IdUtil.getSnowflakeNextIdStr();
        this.inputs = inputs;
        outputs = new HashMap<>();
        this.workflowStatus = new StatusData();
        reports = new HashMap<>();
    }

    public NodeReport addNodeReport(NodeReport nodeReport) {
        // 如果节点已经存在，则更新
        if (reports.containsKey(nodeReport.getId())) {
            return reports.get(nodeReport.getId());
        } else {
            reports.put(nodeReport.getId(), nodeReport);
            return nodeReport;
        }
    }

}
